package com.phantasy.managers
{
	import com.phantasy.common.GlobalObjectManager;
	import com.phantasy.modules.ModuleCommand;
	
	import flash.display.Stage;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;

	/**
	 *缩放管理器 
	 * @author Liseen
	 * 
	 */	
	public class ReSizeManager
	{
		public static var stage:Stage;
		public static var minWidth:int = 1002;
		public static var minHeight:int = 545;
		
		public function ReSizeManager()
		{
		}
		
		public static function init(stage:Stage):void
		{
			stage = stage;
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.addEventListener(Event.RESIZE,onStageResizeHandle);
		}
		
		private static function onStageResizeHandle(event:Event):void
		{
			GlobalObjectManager.GAME_WIDTH = Math.max(stage.stageWidth, minWidth);
			GlobalObjectManager.GAME_HEIGHT = Math.max(stage.stageHeight, minHeight);
			Dispatch.dispatch(ModuleCommand.STAGE_RESIZE,{
			"width":GlobalObjectManager.GAME_WIDTH,
			"height":GlobalObjectManager.GAME_HEIGHT
			});
		}
	}
}